import 'package:flutter/material.dart';
import 'package:get/get_state_manager/src/simple/get_state.dart';

import '../common/constants.dart';
import '../controllers/discover_controller.dart';
import '../widgets/video_rank_list_view.dart';

class VideoRankPage extends StatefulWidget {
  const VideoRankPage({super.key});

  @override
  State<VideoRankPage> createState() => _VideoRankPageState();
}

class _VideoRankPageState extends State<VideoRankPage>
    with SingleTickerProviderStateMixin {
  late TabController _tabController;
  final List<String> _tabs = ["周排行", "月排行", "总排行"];
  final List<String> _rankTypes = ["weekly", "monthly", "historical"];

  @override
  void initState() {
    super.initState();

    _tabController = TabController(length: _tabs.length, vsync: this);
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<DiscoverController>(
      init: DiscoverController(),
      builder: (controller) {
        return Scaffold(
          appBar: AppBar(
            backgroundColor: Colors.white,
            surfaceTintColor: Colors.white,
            title: Image.asset(
              'assets/images/eyepetizer.png',
              fit: BoxFit.contain,
              width: 120,
              height: 25,
            ),
            centerTitle: true,
            bottom: TabBar(
              controller: _tabController,
              indicatorColor: Constants.themeColor,
              indicatorSize: TabBarIndicatorSize.label,
              indicatorPadding: const EdgeInsets.symmetric(vertical: 3),
              labelPadding:
                  const EdgeInsets.symmetric(horizontal: 10, vertical: 0),
              labelStyle: TextStyle(
                  color: Constants.themeColor, fontWeight: FontWeight.w600),
              unselectedLabelStyle: const TextStyle(color: Colors.black54),
              dividerColor: Colors.grey[200],
              splashFactory: NoSplash.splashFactory,
              tabs: _tabs.map((e) => Tab(text: e)).toList(),
            ),
          ),
          body: TabBarView(
            controller: _tabController,
            children:
                _rankTypes.map((e) => VideoRankListView(rankType: e)).toList(),
          ),
        );
      },
    );
  }
}
